<script src="../../../../../../public/static/global/My97DatePicker/WdatePicker.js"></script>
{extend name="$BASE_POPUP_FORM" /}
{block name="body"}
<link rel="stylesheet" type="text/css" href="__STATIC__/easyui/themes/custom/easyui.css" />
<style>
    .edui-editor, .edui-editor-iframeholder {
        width: 790px !important;
    }
    .img_upload_wrp .img_upload_box.img_upload_preview_box{
        width:120px !important;
        height:120px !important;
    }
    .img_box{
        position: relative;
        width: 150px;
        height: 150px;
    }
    .opt_set{
        position: absolute;
        top: 120px;
        width: 100%;
        height: 30px;
        right: 0px;
        background-color: #c2c2c2d1;
    }
    #js_append_img{
        display: inline-flex;
    }
</style>
<div class="box-content">
    <input type="hidden" name="id" id="id" value="{$id}"/>
    <input type="hidden" name="images" id="images_info" value=""/>

    <div class="control-group">
        <label class="control-label">选择图片</label>
        <div class="controls">
            <div class="controls">
                <div id="js_upload_wrp">
                    <input type="hidden" id="images" name="images" value="" class="" />
                    {:hook('picResource',array('name'=>'images','limit_num'=> '5','checktype'=>2,'folder'=>'tour','tips'=>'建议尺寸：800x600像素。仅支持.jpg .png格式长方形照片，大小不超过1M。','callback'=>'selectPicCallBack'))}
                </div>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="script"}

<script type="text/javascript">

    function uploadImgCallback(path) {

        $("#images").val(path);
    }
    function onLoadDataSuccess(data) {
        if (data.images) {
            var images = data.images;
            var arr = images.split(',');
            for (var i = 0; i < arr.length; i++) {
                appendPic('images',arr[i]);
            }
        }
    }

    function chkForm(){
        setPicValue();
        return true;
    }
    /**
     * 设置图片
     * @returns {undefined}
     */
    function setPicValue(){
        var arr = '';
        $(".preview_photo").each(function(){
            var path = $(this).attr('src');
            if(path){
                if(arr != '')
                    arr += ',';
                arr += path;
            }

        })
        $("#images").val(arr)
    }
    /**
     * 点击图片删除
     * */
    $('#js_upload_wrp').on("click", ".js_delete", function (e) {
        var _this = $(this);
        _this.parents(".js_edit_pic_wrp").remove();
        setPicValue()
    });


    function selectPicCallBack(data) {
        var arr = data.split(',')
        $("#images").val(data);
        $("#images_info").val(data);
        for(var i in arr){
            appendPic('images', arr[i])
        }
    }
</script>
{/block}


